<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>栏目添加</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/Public/Admin/css/bootstrap.min14ed.css" rel="stylesheet">
    <link href="/Public/Admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/Public/Admin/css/style.min862f.css" rel="stylesheet">
    <link href="/Public/Admin/js/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="/Public/Admin/css/plugins/switchery/switchery.min.css" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加栏目</h5>
                </div>
                <div class="ibox-content">
                    <form method="post" name="form1" id="form1" action="<?php echo U('Columns/save');?>" class="form-horizontal">
                    <input type="hidden" name="id" value="<?php echo ($columnsInfo["id"]); ?>">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">父ID</label>
                            <select name="pid" value="<?php echo ($columnsInfo['pid']); ?>">
                                <option value="">--==请选择父ID==--</option>
                                <?php if(is_array($list)): foreach($list as $key=>$va): ?><option value="<?php echo ($va['pid']); ?>" <?php if($va['pid'] == $columnsInfo['pid'] and ($va['columns'] == $columnsInfo['columns'])): ?>selected<?php endif; ?>><?php echo ($va["html"]); echo ($va["pid"]); ?>(<?php echo ($va["columns"]); ?>)</option><?php endforeach; endif; ?>
                               
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">栏目名称</label>
                            <div class="col-sm-10">
                                <input type="text" name="columns" id="columns" class="form-control" value="<?php echo ($columnsInfo["columns"]); ?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">SEO标题</label>
                            <div class="col-sm-10">
                                <input type="text" name="seo_title" id="seo_title" class="form-control" value="<?php echo ($columnsInfo["seo_title"]); ?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">SEO关键词</label>
                            <div class="col-sm-10">
                                <input type="text" name="seo_keyword" id="seo_keyword" class="form-control" value="<?php echo ($columnsInfo["seo_keyword"]); ?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">SEO描述</label>
                            <div class="col-sm-10">
                                <input type="text" name="seo_description" id="seo_description" class="form-control" value="<?php echo ($columnsInfo["seo_description"]); ?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">排序</label>
                            <div class="col-sm-10">
                                <input type="text" name="sort" id="sort" class="form-control" value="<?php echo ($columnsInfo["sort"]); ?>">
                            </div>
                        </div>
                        <div class="form-group">
                        <label class="col-sm-2 control-label">类型：
                            </label>
                            <div class="col-sm-10">
                                <label class="radio-inline">
                                <input type="radio" checked="" value="1" id="type" name="type">文章</label>
                                <label class="radio-inline">
                                <input type="radio" value="2" id="type" name="type">产品</label>
                            </div>
                        </div>
                        <div class="form-group">
                        <label class="col-sm-2 control-label">前台栏目：
                            </label>
                            <div class="col-sm-10">
                                <label class="radio-inline">
                                <input type="radio" checked="" value="0" id="is_nav" name="is_nav">是</label>
                                <label class="radio-inline">
                                <input type="radio" value="1" id="is_nav" name="is_nav">否</label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">状态</label>
                            <div class="col-sm-10">
                                <input type="checkbox" value="1" name="status" id="status" class="js-switch" checked>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-10 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">添加</button>
                                <button class="btn btn-white" type="reset"  onclick="history.go(-1)">取消</button>
                            </div>
                        </div>
                    </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/Public/Admin/js/jquery.min.js"></script>
<script src="/Public/Admin/js/bootstrap.min.js"></script>
<script src="/Public/Admin/js/plugins/layer/layer.min.js"></script>
<script src="/Public/Admin/js/plugins/switchery/switchery.min.js"></script>
<script src="/Public/Admin/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/Public/Admin/js/plugins/validate/messages_zh.min.js"></script>
<script src="/Public/Admin/js/common.js"></script>
<script>
    $(function(){
        $("#form1").validate({
            rules:{
                pid:"required",
                columns:"required",
                seo_title:"required",
                seo_keyword:"required",
                seo_description:"required",
                sort:"required"
            },
            messages:{
                pid:'父ID不能为空',
                columns:'栏目名称不能为空!',
                seo_title:'SEO标题不能为空！',
                seo_keyword:'SEO关键词不能为空！',
                seo_description:'SEO描述不能为空！',
                sort:'排序不能为空！',
            },
            submitHandler: function (form) {
                var objNames = $(form).serializeArray();
                var dataNames = new Object();
                $.each(objNames,function(key,val){
                    dataNames[val.name] = val.value;
                });
                $.ajax({
                        url:$(form).attr('action'),
                        type:'post',
                        dataType:'json',
                        data:dataNames,
                        success:function(data){
                           if(data.status > 0){
                               common.error(data.msg);
                           }else{
                               common.success(data.msg,"<?php echo U('columns/index');?>");
                           }
                        }
                });
            }
        });
    });
    var elem = document.querySelector('.js-switch');
    var switchery = new Switchery(elem, { });
</script>
</html>